﻿<link href="@Url.Content("~/content/activitie_detail.css")" rel="stylesheet" type="text/css"/>

@model PessMvc.Models.ArchivesModel

@{
    ViewBag.Title = "档案列表";
    
    bool hideArchiveDetails = false;
    hideArchiveDetails = Roles.IsUserInRole("ExpertJudge")
        && ViewBag.HideArchiveDetails != null
        && ViewBag.HideArchiveDetails == true;
}
@*@Html.Partial("_ActivityNavPartial",ViewData["ActivityID"])*@
@{
    string status="";
    if(Roles.IsUserInRole("ExpertJudge")){
         status=string.Format("（已评：{0}  /  总数：{1}）", Model.ReviewHistory.Count, Model.PageInfo.TotalItems);
    }
}
<div id="m-title">
    <h2>档案及评分</h2><span style="font-size:12px;"> @status</span>
    @*<p>
     @Html.DisplayFor(model => Model.SingleOrDefault().Subject.Activity.Name)
    </p>*@
        <div id="m-op">
            <span class="u-uf-show ie-11">
                @using (Html.BeginForm("Index", "Archive", FormMethod.Get))
                {
                    @Html.Hidden("ActivityID", ViewData["ActivityID"])
                    @Html.TextBox("KeyWord", null, null, new { @class = "u-it" })
                    <input type="submit" value="搜索" class="u-btn" />
                }
            </span>
            @if (Roles.IsUserInRole(Membership.GetUser().UserName, "Admin") || Roles.IsUserInRole(Membership.GetUser().UserName, "CountyAdmin"))
            {
                if ((bool)ViewBag.IsArchiveModificationAllowed == true)
                {
                    <span class="u-uf-show ie-13">
                        @Html.ActionLink("新建", "Create", new { activityID = ViewData["ActivityID"] }, new { @class = "u-btn-a" })
                    </span>
                }
                if (Roles.IsUserInRole("Admin"))
                {
                    <span class="u-uf-show ie-12">
                        @using (Html.BeginForm("ImportReviewFeedbacks", "Archive", FormMethod.Post))
                        {
                            @Html.DropDownList("SubjectID")
                            <input type="submit" value="导入评审意见" class="u-btn f-btn-long" id="fly-btn" name="fly-btn" />
                        }
                    </span>
                }
            }
            
            @if (!hideArchiveDetails)
            {
                <span class="u-uf-show ie-14">@Html.ActionLink("导出档案清单", "ExportArchiveList", "Archive", new { activityID = ViewData["ActivityID"] }, new { @class = "u-btn-a f-btn-long" })</span>
            }
        </div>
</div>

    @using(@Html.BeginForm("SetExpertGroup","Archive",FormMethod.Post)){
    <table id="fileList" class="oddTable">
        <tr>
            <th></th>
            <th class="thTitle">
                @*@PessResources.Archive.ProjectTitle*@
            @Model.ArchiveProjectTitleDisplayName
        </th>
        <th class="thSName">
            @*@PessResources.Archive.SerialNumber*@
            @Model.ArchiveSerialNumberDisplayName
        </th>
        <th class="thSName">
            @*@PessResources.Archive.SubjectName*@
            @Model.ArchiveSubjectNameDisplayName
        </th>
        <th class="thCName">
            @*@PessResources.Archive.CountyName*@
            @Model.ArchiveCountyNameDisplayName
        </th>
        <th class="thTName">
            @*@PessResources.Archive.TeacherName*@
            @Model.ArchiveTeacherNameDisplayName
        </th>
        @*<th class="thLevel">
           @PessResources.Archive.GradeLevel
        </th>*@
        <th class="thSCName">
            @*@PessResources.Archive.SchoolName*@
            @Model.ArchiveSchoolNameDisplayName
        </th>
        <th style="width:65px">
            评委组
        </th>
        <th class="thAction" style="width:110px"></th>
    </tr>
@{int x = 0;}
@foreach (var item in Model.All) {
    <tr>
        <td class="f-ck-mid">@Html.CheckBox("Archives["+x+"].IsSelected")
            @Html.Hidden("Archives["+x+"].ArchiveID",item.ID)
        </td>
        <td class="thTitle">
            @Html.DisplayFor(modelItem=>item.ProjectTitle)
        </td>
        <td class="thSName">
            @Html.DisplayFor(modelItem => item.SerialNumber)
        </td>
        <td class="thSName">
            @Html.DisplayFor(modelItem => item.Subject.Name)
        </td>
        <td class="thCName">
            @if(!hideArchiveDetails)
            {
                @Html.DisplayFor(modelItem => item.County.Name)
            }
        </td>
        <td class="thTName">
            @if(!hideArchiveDetails)
            {
                @Html.DisplayFor(modelItem => item.TeacherName)
            }
        </td>
        @*<td class="thLevel">
            @Html.DisplayFor(modelItem => item.GradeLevel)
        </td>*@
        <td class="thSCName">
            @if(!hideArchiveDetails)
            {
                @Html.DisplayFor(modelItem =>item.SchoolName)
            }
        </td>    
        <td>
            @if(!hideArchiveDetails)
            {
                if(item.ExpertGroup!=null){@item.ExpertGroup.Callsign}
            }
        </td>   
        <td class="thAction">
        @{bool showDelete=false,showDetails=false;}
        @if(Roles.IsUserInRole(Membership.GetUser().UserName,"Admin"))
        {
            showDelete = true; showDetails = true;
        }
        else if (Roles.IsUserInRole(Membership.GetUser().UserName, "CountyAdmin"))
        {
            showDetails = true;
            if (ViewBag.IsArchiveModificationAllowed) { showDelete = true; }
        }
        @if(showDelete){
            @Html.ActionLink("删除", "Delete", new { id=item.ID })
        }
        @if(showDetails){
            @Html.ActionLink("详细", "Details", new { id=item.ID }) 
        }
        @if(Roles.IsUserInRole(Membership.GetUser().UserName,"ExpertJudge"))
        {
            if(ViewBag.IsScoreInputAllowed)
            {
                @Html.ActionLink("评分", "Grade", new { archiveID=item.ID })
            }
            if (Model.ReviewHistory.Select(r => r.ArchiveID).Contains(item.ID)) 
            { @Html.Label("已评", new {@class="f-graded" })}
            else
            {
                @Html.Label("未评", new {@class="f-grade" })
            }
        }
        </td>
    </tr>
    {x = x + 1;}
}

</table>
if(Roles.IsUserInRole(Membership.GetUser().UserName,"Admin")){   
<div style="padding-top:20px">    <span>将档案分配到评委组：</span>

    @Html.DropDownList("ExpertGroupID",new SelectList(Model.ExpertGroups,"ID","Callsign"))

    @Html.Hidden("Page", Model.PageInfo.CurrentPage)
    <input type="submit" value="分配" class="u-btn" />
</div>
}
}

<div id="pageNum">@Html.PageLinks(Model.PageInfo,u=>Url.Action("Index","Archive",new {ActivityID=Model.ActivityID,SubjectID=Model.SubjectID,Keyword=Model.Keyword,Page=u}))</div>

<script language="javascript">
  //  var l = document.getElementById("fly-btn");
    //alert(document.getElementById("SubjectID").options.length)
  //  if (document.getElementById("SubjectID").options.length == 0) {
   //     l.disabled = true;
     //   l.title= "请先选择所属类别";
     //   l.alt = "请先选择所属类别";
    //}
</script>